<?php

class Application_Form_Basic extends Zend_Form
{

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
    }
    
    public function processUploadedFiles() {
		$adapter =  $this->photos->getTransferAdapter();
		$receivingOK = true;
		foreach ($adapter->getFileInfo() as $file => $info) {
		    if($info['name']){
		        $originalFilename = pathinfo($info['name']);
			    $adapter->addFilter('Rename', md5(uniqid(rand(),1)) . substr(time(), -10, 10) . '.' . $originalFilename['extension'], $file);
			    if (!$adapter->receive($file)) {
			         $receivingOK = false;
			    }
		    }
		}

		if(!$receivingOK){
			throw new Exception('Error uploading files!');
		}

		$this->photos->receive();
	}
}

